//
//  AlreadyBorrowView.m
//  BrushFace
//
//  Created by 吕海瑞 on 15/12/26.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "AlreadyBorrowView.h"
#import "NavHelper.h"
#import "ARViewHepler.h"
@implementation AlreadyBorrowView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = self.frame.size.width/2;
        UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(15, 10, 36, 15)];
        lable.center = CGPointMake(frame.size.width/2, 20);
        lable.text = @"已借";
        
        [lable setTextAlignment:NSTextAlignmentCenter];
        [lable setTextColor:[UIColor whiteColor]];
        
        [lable setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:lable];
        
        _alreadyBorrowNum = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, frame.size.width-20, 18)];
        _alreadyBorrowNum.center = CGPointMake(frame.size.width/2, frame.size.height/2+5);
        //_alreadyBorrowNum.backgroundColor = [UIColor redColor];
        _alreadyBorrowNum.textAlignment = NSTextAlignmentCenter;
        _alreadyBorrowNum.text = @"0";
        [_alreadyBorrowNum setTextColor:[UIColor whiteColor]];
        [_alreadyBorrowNum setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:_alreadyBorrowNum];
        
        UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(self.frame.size.width-11, 25, 11, 20)];
        image.image = [UIImage imageNamed:@"BackButtonRight@2x"];
        // BackButtonRight@2x
        [self addSubview:image];
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
        [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:btn];
    }
    return self;
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

-(void)setNum:(NSString *)num
{
    _num = num;
    if([_num integerValue]>9999)
    {
        _alreadyBorrowNum.text = [NSString stringWithFormat:@"%.2f万",[_num floatValue]/10000.0];
       
    }
    else
    {
        _alreadyBorrowNum.text = num;
        
    }
    
}

-(void)btnClick
{
    [NavHelper gotoAssetsRecordVC:AR_BORROW_ING andBaseType:TYPE_BORROW_IN andHopeId:self.hopeid];
    
}
- (void)setViewHopeIDWithHopeid:(NSString *)hopeid{
    self.hopeid = hopeid;
}

@end
